package com.ninthgroup.controller;

import com.ninthgroup.entity.MessageBooking;
import com.ninthgroup.entity.User;
import com.ninthgroup.service.MessageBookingService;
import com.ninthgroup.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @author wch
 * @version 1.0
 * @date 2022/10/14 19:07
 */
@RestController
@RequestMapping("/messagebook")
public class MessageBookingController {
    @Autowired
    private MessageBookingService messageBookingService;

    //查询用户所有预约信息
    @RequestMapping("/list")
    public Result lest() {
        return messageBookingService.selectAll();
    }

    //预约添加
    @RequestMapping("/add")
    @ResponseBody
    public Result add(@RequestBody MessageBooking messageBooking) {
        return messageBookingService.insertAdd(messageBooking);
    }

    //    删除预约信息
    @RequestMapping("/delete")

    public Result delete(Integer mId) {
        return messageBookingService.delecte(mId);
    }

    //修改预约信息
    @RequestMapping("/update")
    @ResponseBody
    public Result update(@RequestBody MessageBooking messageBooking) {
        return messageBookingService.update(messageBooking);
    }

    // 用户查询病因和建议

    @RequestMapping("/selectbing")
    public Result selectbing() {
        return messageBookingService.selectbing();
    }


    @GetMapping("/updated")
    public Result saveDidAndStatus(Integer mId, Integer dId) {
        return messageBookingService.saveDidAndStatus(mId, dId);

    }


    //统计患者男女比例
    @RequestMapping("selectSex")
    public Result selectSex() {
        return messageBookingService.selectBysex();
    }

    //统计患者年龄
    @RequestMapping("selectByAge")
    public Result selectByAge() {
        return messageBookingService.selectByAge();
    }


    /**
     * fetch data by show
     *
     * @param
     * @return com.ninthgroup.vo.Result
     * @create by: 1452863884@qq.com rcg
     * @description:营收折线统计图
     * @create time: 2022/11/6 23:11
     */
    @RequestMapping("/income")
    public Result income() {
        return messageBookingService.selectByAllMoney();
    }
}
